<template>
  <div class="_wz_accountLabor">
    <Card dis-hover :bordered="true">
      <template #title>搜索</template>
      <Form ref="formSearch" :model="formDataSearch" label-position="right" :label-width="100" inline>
        <FormItem label="人员名称">
          <i-input v-model="formDataSearch.driverName" placeholder="请输入人员名称" clearable />
        </FormItem>
        <FormItem label="经营企业">
          <i-input v-model="formDataSearch.deptName" placeholder="请输入经营企业" clearable />
        </FormItem>

        <FormItem>
          <Button type="primary" @click="searchSubmit">搜索</Button>
        </FormItem>
      </Form>
    </Card>
    <Card dis-hover :bordered="true" style="height: 100%;overflow: hidden;margin: 10px 0 0;">
      <template #title>列表</template>
      <wzTbale ref="wzTbale" :tableData="tableData"></wzTbale>
    </Card>


  </div>
</template>
<script>


import {resolveComponent,getCurrentInstance,inject,nextTick,reactive, toRefs,toRef,onBeforeMount,onMounted,onBeforeUpdate,onUpdated,onBeforeUnmount,onUnmounted, ref,defineComponent,toRaw,watch} from 'vue'
import { useRouter,useRoute } from "vue-router";

import { useMainStore } from '../../../store'  //pinia 使用 类似 vuex
import { storeToRefs } from 'pinia'//pinia 使用 类似 vuex
const mainStore = useMainStore() //pinia 使用 类似 vuex


import wzTbale from "../../../components/table/index.vue";
import {systemDictList} from "../../../util/commonInterfaces.js";//字典接口

//reactive
export default defineComponent({
  name: 'accountLabor',//组件名称
  components: {
    wzTbale,//表格
  },//组件引用
  setup (props,context) {


    const apiUrl = inject('$apiUrl'); // 变量全局化 后台地址
    const $axios = inject('$axiosInterceptor');// 变量全局化 axios
    const $ViewUIPlus = inject('$ViewUIPlus');//引用全局组件
    const router = useRouter();//路由跳转使用

    // 用于获取$refs
    const wzTbale = ref();


    const state = reactive({
      formDataSearch:{},//搜索条件

      tableData: {
        url: apiUrl.safetyAccountAccountLaborPageList,//请求地址
        method: 'post',//请求方式
        where: {},//搜索条件
        height: '100%',//表格高度 auto
        page: true,//分页是否使用
        columns: [//表头数据
          {type: 'index', width: 70, align: 'center', title: '序号'},
          {title: '经营企业', minWidth: 240, key: 'deptName',tooltip:true,resizable: true,},
          {title: '运输类型', minWidth: 120, key: 'deptTransportName',tooltip:true,resizable: true,},
          {title: '人员名称', minWidth: 100, key: 'laborPersonnel',tooltip:true,resizable: true,},
          {title: '手套', minWidth: 100, key: 'laborMittens',tooltip:true,resizable: true,render: (h, params) => {
              return   h('span', !!params.row.laborMittens ? params.row.laborMittens + ' 个' : 0)
            }
          },
          {title: '口罩', minWidth: 100, key: 'laborMask',tooltip:true,resizable: true,render: (h, params) => {
              return   h('span', !!params.row.laborMask ? params.row.laborMask + ' 个' : 0)
            }
          },
          {title: '工作服', minWidth: 100, key: 'laborCoverall',tooltip:true,resizable: true,render: (h, params) => {
              return   h('span', !!params.row.laborCoverall ? params.row.laborCoverall + ' 个' : 0)
            }
          },
          {title: '工作鞋', minWidth: 100, key: 'laborShoes',tooltip:true,resizable: true,render: (h, params) => {
              return   h('span', !!params.row.laborShoes ? params.row.laborShoes + ' 个' : 0)
            }
          },
          {title: '防寒服', minWidth: 100, key: 'laborWinterClothes',tooltip:true,resizable: true,render: (h, params) => {
              return   h('span', !!params.row.laborWinterClothes ? params.row.laborWinterClothes + ' 个' : 0)
            }
          },
          {title: '雨衣', minWidth: 100, key: 'laborRaincoat',tooltip:true,resizable: true,render: (h, params) => {
              return   h('span', !!params.row.laborRaincoat ? params.row.laborRaincoat + ' 个' : 0)
            }
          },
          {title: '护目镜', minWidth: 100, key: 'laborGoggles',tooltip:true,resizable: true,render: (h, params) => {
              return   h('span', !!params.row.laborGoggles ? params.row.laborGoggles + ' 个' : 0)
            }
          },
          {title: '急救药箱', minWidth: 100, key: 'laborFirstAidKit',tooltip:true,resizable: true,render: (h, params) => {
              return   h('span', !!params.row.laborFirstAidKit ? params.row.laborFirstAidKit + ' 个' : 0)
            }
          },
          {title: '安全帽', minWidth: 100, key: 'laborSafetyHat',tooltip:true,resizable: true,render: (h, params) => {
              return   h('span', !!params.row.laborSafetyHat ? params.row.laborSafetyHat + ' 个' : 0)
            }
          },
          {title: '其他用品', minWidth: 100, key: 'laborOthers',tooltip:true,resizable: true,render: (h, params) => {
              return   h('span', !!params.row.laborOthers ? params.row.laborOthers + ' 个' : 0)
            }
          },
          {title: '创建时间', minWidth: 160, key: 'createTime',tooltip:true,resizable: true,},
        ],
        pagingParameters:{// 分页参数
          page:'pageNo',
          limit:'pageSize'
        },
        format: {//返回数据格式
          list: ['data'],//数据list
          count: ['count'],//数据总量
        },
      },

    });



    //搜索方法
    const searchSubmit = ()=>{
      let formDataSearch = JSON.parse(JSON.stringify(state.formDataSearch));
      state.tableData.where = formDataSearch;
      wzTbale.value.tableLoadData(true)

    }




    // 其他的生命周期
    onBeforeMount (() => {//beforeMount挂载前状态 // console.log("App ===> 相当于 vue2.x 中 beforeMount")

    })
    onMounted (async() => {//mounted 挂载结束状态  // console.log("App ===> 相当于 vue2.x 中 mounted")

    })

    // 注意，onBeforeUpdate 和 onUpdated 里面不要修改值
    onBeforeUpdate (() => {//beforeUpdate 更新前状态 // console.log("App ===> 相当于 vue2.x 中 beforeUpdate")

    })

    onUpdated (() => {//updated 更新完成状态 // console.log("App ===> 相当于 vue2.x 中 updated")

    })

    onBeforeUnmount (() => {//beforeDestroy 销毁前状态  // console.log("App ===> 相当于 vue2.x 中 beforeDestroy")
    })

    onUnmounted (() => {//destroyed 销毁完成状态  // console.log("App ===> 相当于 vue2.x 中 destroyed")
    })

    return {
      ...toRefs(state),
      searchSubmit,//搜索方法
      wzTbale,// ref 使用 封装的表格
    }
  }
})


</script>
<style lang="less">
._wz_accountLabor{
  padding: 10px;
  height: 100%;
  display: flex;
  flex-direction: column;

  .ivu-card-body {
    height: calc(100% - 51px);
  }
}
</style>
